package com.permgmt.utils;

import com.permgmt.entity.model.ResultFormat;

/**
 * @author LIAO
 */
public class ResultUtil {

    public static ResultFormat success(Object object) {
	ResultFormat result = new ResultFormat();
	result.setCode(200);
	result.setMsg("成功");
	result.setData(object);
	return result;
    }

    public static ResultFormat success(Integer code, String msg, Object object) {
	ResultFormat result = new ResultFormat();
	result.setCode(code);
	result.setMsg(msg);
	result.setData(object);
	return result;
    }

    public static ResultFormat success(Integer code, String msg) {
	ResultFormat result = new ResultFormat();
	result.setCode(code);
	result.setMsg(msg);
	return result;
    }

    public static ResultFormat success(String msg) {
	ResultFormat result = new ResultFormat();
	result.setCode(200);
	result.setMsg(msg);
	return result;
    }

    public static ResultFormat success(String msg, Object object) {
	ResultFormat result = new ResultFormat();
	result.setCode(200);
	result.setMsg(msg);
	result.setData(object);
	return result;
    }

    public static ResultFormat success() {
	ResultFormat result = new ResultFormat();
	result.setCode(200);
	result.setMsg("成功");
	return result;
    }

    public static ResultFormat error() {
	ResultFormat result = new ResultFormat();
	result.setCode(100);
	result.setMsg("失败");
	return result;
    }

    public static ResultFormat error(Integer code, String msg) {
	ResultFormat result = new ResultFormat();
	result.setCode(code);
	result.setMsg(msg);
	return result;
    }

    public static ResultFormat result(boolean flag) {
	return flag ? success() : error();
    }
}
